<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D旋转盒子</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background-image: linear-gradient(to right, red, green, blue);
        }
        
        header {
            color: white;
            font-size: 40px;
            font-weight: bold;
            text-align: center;
            padding-top: 100px;
        }
        
        main {
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            transform-style: preserve-3d;
            animation: rotate3D 10s ease-in-out infinite;
        }
        
        main>div {
            position: absolute;
            width: 250px;
            height: 250px;
            background-size: cover;
            opacity: 0.7;
            border-radius: 6px;
            box-shadow: inset 2px 2px 2px 2px rgba(255, 255, 255, 0.1);
        }
        /* 前 */
        
        main .img1 {
            background-image: url(./images/1.jpeg);
            transform: translateZ(125px);
        }
        /* 左 */
        
        main .img2 {
            background-image: url(./images/2.jpeg);
            transform: rotateX(-90deg) translateZ(125px);
        }
        /* 右 */
        
        main .img3 {
            background-image: url(./images/3.jpeg);
            transform: rotateX(90deg) translateZ(125px);
        }
        /* 上 */
        
        main .img4 {
            background-image: url(./images/4.jpeg);
            transform: rotateY(90deg) translateZ(125px);
        }
        /* 下 */
        
        main .img5 {
            background-image: url(./images/5.jpeg);
            transform: rotateY(-90deg) translateZ(125px);
        }
        /* 后 */
        
        main .img6 {
            background-image: url(./images/6.jpeg);
            transform: rotateY(-180deg) translateZ(125px);
        }
        
        @keyframes rotate3D {
            0% {
                transform: rotateY(125deg) rotateX(0);
            }
            20% {
                transform: rotateX(90deg);
            }
            40% {
                transform: rotateY(90deg);
            }
            60% {
                transform: rotateX(-90deg);
            }
            80% {
                transform: rotateY(-90deg);
            }
            100% {
                transform: rotateY(0) rotateX(0);
            }
        }
    </style>
</head>

<body>
    <header>3D旋转盒子</header>
    <main>
        <div class="img1"></div>
        <div class="img2"></div>
        <div class="img3"></div>
        <div class="img4"></div>
        <div class="img5"></div>
        <div class="img6"></div>
    </main>
    <input type="range">
</body>

</html>